package com.example.myapp1211.Fragments;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.myapp1211.R;
import com.example.myapp1211.bean.ChatUser;

import java.util.List;

public class ChatUserAdapter extends ArrayAdapter {
    int resourceId;
    public ChatUserAdapter(@NonNull Context context,  int textViewResourceId, List<ChatUser> objects) {
        super(context,textViewResourceId, objects);
        resourceId = textViewResourceId;
    }

    public View getView(int position, View convertView, ViewGroup parent){
        ChatUser chatUser = (ChatUser) getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,null);
        ImageView ChatUserImage = (ImageView) view.findViewById(R.id.chatuser_image);
        TextView ChatUserName = (TextView) view.findViewById(R.id.chatuser_name);
        TextView ChatUserContent = (TextView) view.findViewById(R.id.chatuser_content);
        ChatUserImage.setImageResource(chatUser.getImageid());
        ChatUserName.setText(chatUser.getName());
        ChatUserContent.setText(chatUser.getContent());
        return view;
    }
}
